home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / k3bfileitem.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-05-27  |  3.1 KB  |  125 lines

  1. /* 
  2.  *
  3.  * $Id: k3bfileitem.h 619556 2007-01-03 17:38:12Z trueg $
  4.  * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
  5.  *
  6.  * This file is part of the K3b project.
  7.  * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  * See the file "COPYING" for the exact licensing terms.
  14.  */
  15.  
  16.  
  17. #ifndef K3BFILEITEM_H
  18. #define K3BFILEITEM_H
  19.  
  20.  
  21. #include "k3bdataitem.h"
  22. #include <k3bglobals.h>
  23.  
  24. #include <kio/global.h>
  25. #include <qstring.h>
  26.  
  27. #include "k3b_export.h"
  28.  
  29. class K3bDataDoc;
  30. class K3bDirItem;
  31.  
  32.  
  33. /**
  34.   *@author Sebastian Trueg
  35.   */
  36. class LIBK3B_EXPORT K3bFileItem : public K3bDataItem
  37. {
  38. public:
  39.   /**
  40.    * Creates a new K3bFileItem
  41.    */
  42.   K3bFileItem( const QString& fileName, K3bDataDoc* doc, K3bDirItem* dir, const QString& k3bName = 0, int flags = 0 );
  43.  
  44.   /**
  45.    * Constructor for optimized file item creation which does no additional stat.
  46.    *
  47.    * Used by K3b to speedup file item creation.
  48.    */
  49.   K3bFileItem( const k3b_struct_stat* stat, 
  50.            const k3b_struct_stat* followedStat, 
  51.            const QString& fileName, K3bDataDoc* doc, K3bDirItem* dir, const QString& k3bName = 0 );
  52.  
  53.   /**
  54.    * Default copy constructor
  55.    * Creates a copy of the fileitem. The copy, however, is not an exact duplicate of this item.
  56.    * The copy does not have a parent dir set and any old session items are set to 0.
  57.    */
  58.   K3bFileItem( const K3bFileItem& );
  59.  
  60.   virtual ~K3bFileItem();
  61.  
  62.   virtual K3bDataItem* copy() const;
  63.     
  64.   bool exists() const;
  65.  
  66.   QString absIsoPath();
  67.  
  68.   /** reimplemented from K3bDataItem */
  69.   QString localPath() const;
  70.  
  71.   /**
  72.    * Identification of the files on the local device.
  73.    */
  74.   struct Id {
  75.     dev_t device;
  76.     ino_t inode;
  77.   };
  78.  
  79.   /**
  80.    * This is not the normal inode number but it also contains
  81.    * the device number.
  82.    */
  83.   Id localId() const;
  84.  
  85.   /**
  86.    * The id of the file the symlink is pointing to
  87.    */
  88.   Id localId( bool followSymlinks ) const;
  89.  
  90.   K3bDirItem* getDirItem() const;
  91.     
  92.   bool isSymLink() const;
  93.   QString linkDest() const;
  94.   bool isFile() const { return true; }
  95.  
  96.   /** returns true if the item is not a link or 
  97.    *  if the link's destination is part of the compilation */
  98.   bool isValid() const;
  99.  
  100.   K3bDataItem* replaceItemFromOldSession() const { return m_replacedItemFromOldSession; }
  101.   void setReplacedItemFromOldSession( K3bDataItem* item ) { m_replacedItemFromOldSession = item; }
  102.  
  103.   /**
  104.    * Normally one does not use this method but K3bDataItem::size()
  105.    */
  106.   KIO::filesize_t itemSize( bool followSymlinks ) const;
  107.  
  108.  private:
  109.   K3bDataItem* m_replacedItemFromOldSession;
  110.  
  111.   KIO::filesize_t m_size;
  112.   KIO::filesize_t m_sizeFollowed;
  113.   Id m_id;
  114.   Id m_idFollowed;
  115.  
  116.   QString m_localPath;
  117.   bool m_bSymLink;
  118. };
  119.  
  120. bool operator==( const K3bFileItem::Id&, const K3bFileItem::Id& );
  121. bool operator<( const K3bFileItem::Id&, const K3bFileItem::Id& );
  122. bool operator>( const K3bFileItem::Id&, const K3bFileItem::Id& );
  123.  
  124. #endif
  125.